package club.jdiy.core.convert;


import java.math.BigDecimal;
import java.math.BigInteger;

class ShortConverter extends NumberConverter<Short> {

    public ShortConverter(Short source) {
        super(source);
    }

    @Override
    public Boolean getBoolean() {
        return source != 0;
    }

    @Override
    public Byte getByte() {
        if (source > Byte.MAX_VALUE || source < Byte.MIN_VALUE) {
            throw __throw(Byte.class);
        } else {
            return source.byteValue();
        }
    }

    @Override
    public Short getShort() {
        return getSource();
    }

    @Override
    public BigDecimal getBigDecimal() {
        return BigDecimal.valueOf(source);
    }

    @Override
    public BigInteger getBigInteger() {
        return BigInteger.valueOf(source);
    }
}
